﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ECGadmin.Common;
using ECGadmin.DAL;
using ECGadmin.WebUI.Attributes;
using ECGadmin.WebUI.Models;

namespace ECGadmin.WebUI.Controllers
{
    [AdminLoggedAuthorize]
    public class ProductCommentController : Controller
    {
        //
        // GET: /ProductComment/

        public ActionResult Index(int page = 1)
        {
            // Product comment
            
            var itemsPerPage = 10;
            var totalPage = 0;
            var model = ProductCommentDb.GetAllProductCommentWithPagging(page, itemsPerPage, ref totalPage) ?? new List<ProductCommentDto>();
            ViewBag.PageInfo = new PageInfo { CurrentPage = page, PageSize = itemsPerPage, TotalPages = totalPage };
            return View(model);
        }
        public JsonResult ProducCommentUpdate(int pId, bool agree, bool active)
        {
            var data = ProductCommentDb.UpDateActive_ProductComment(pId, agree, active);
            return Json(data, JsonRequestBehavior.AllowGet);
        }
        public JsonResult ProducCommentDel(int pId)
        {
            var data = ProductCommentDb.Delete(pId);
            return Json(data, JsonRequestBehavior.AllowGet);
        }
    }
}
